package com.oocl.o2o.client.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.oocl.o2o.client.dao.AdvertisementDao;
import com.oocl.o2o.client.entity.Advertisement;
import com.oocl.o2o.client.service.AdvertisementService;
import com.oocl.o2o.client.util.ConfigBaseUtil;
import com.oocl.o2o.client.vo.AdvertisementVO;
@Service
public class AdvertisementServiceImpl implements AdvertisementService {

	@Resource
	private AdvertisementDao advertisementDao;
	@Override
	public List<AdvertisementVO> findAll() {
		List<Advertisement> advertisements = advertisementDao.findAll();
		List<AdvertisementVO> advertisementVOs = new ArrayList<AdvertisementVO>();
		for(Advertisement a: advertisements){
			AdvertisementVO advertisementVO = new AdvertisementVO();
			advertisementVO.setId(a.getId());
			advertisementVO.setFoodID(a.getFood().getId());
			advertisementVO.setFoodImg(ConfigBaseUtil.getPropertiesInfo("imgPrefix")+a.getFood().getImage());
			advertisementVO.setMerchantID(a.getMerchant().getId());
			advertisementVO.setStatus(a.getAdvertisementStatus());
			advertisementVOs.add(advertisementVO);
		}
		return advertisementVOs;
	}

}
